package com.tianji.learning.controller;


import com.tianji.api.dto.leanring.LearningLessonDTO;

import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author hc
 * @since 2024-08-22
 */
@Api(tags = "学习记录相关接口")
@RestController
@RequestMapping("/learning-records")
public class LearningRecordController {

    @Autowired
    private ILearningRecordService learningRecordService;


    /**
     * 查询当前用户指定课程的学习进度
     * @param courseId 课程id
     * @return 课表信息、学习记录及进度信息
     */
    @GetMapping("course/{courseId}")
    @ApiOperation("查询当前用户指定课程的学习进度")
    public LearningLessonDTO queryLearningRecordByCourse(@PathVariable("courseId") Long courseId){
        return learningRecordService.queryLearningRecordByCourse(courseId);
    }

    /**
     * 提交学习记录
     * @param learningRecordFormDTO
     */
    @PostMapping
    @ApiOperation("提交学习记录")
    public void saveLearningRecord(@RequestBody LearningRecordFormDTO learningRecordFormDTO){
        learningRecordService.saveLearningRecord(learningRecordFormDTO);
    }


}
